Skip to content

Validate tumor types before annotating input files - #248

Open
AleksaGavric wants to merge 4 commits into
oncokb:masterfrom
AleksaGavric:fix/tumor-type-validation
Open

AleksaGavric wants to merge 4 commits into
oncokb:masterfrom
AleksaGavric:fix/tumor-type-validation

Conversation

@AleksaGavric

@AleksaGavric AleksaGavric commented Nov 30, 2026 •

Copy link
Copy Markdown

Unknown tumor types such as BLAH currently reach annotation requests and can produce generic results. Validate tumor types before annotation or output-file creation in the MAF, CNA, fusion and structural-variant commands.

Use the OncoTree release reported by the selected OncoKB server's /api/v1/info. Accept codes, names, main types and OncoKB special tumor types case-insensitively, including MDS/MPN. Preserve clinical-file > input-row > default precedence, sample filters and optional empty types; trim surrounding whitespace in submitted types. GISTIC uses its clinical/default types.

Unknown values and unavailable/malformed metadata exit with status 2 before creating or overwriting output. This adds an OncoTree metadata request when a nonempty tumor type needs validation; a custom OncoKB instance must report a version available from that service. The OncoKB bearer token is never forwarded to OncoTree. README and CLI help describe the behavior.

The test workflow also supports manual runs. Hosted validation exposed an existing runner incompatibility: ubuntu-latest now resolves to Ubuntu 26.04, which has no setup-python build for Python 3.9. Use compatible Ubuntu 24.04 and macOS Intel images for the Python 3.8–3.13 matrix, update the official setup/checkout actions, and run the same flake8 configuration directly without extra check-write permissions. All 18 OS/Python combinations are retained.

Validation

  • Fourteen invalid-input cases failed against the unchanged baseline.
  • Full local suite on Python 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 (macOS arm64): 73 passed, 11 skipped per version. The skipped tests are the existing live-annotation tests requiring an OncoKB token. Flake8 passes.
  • Hosted CI run on d7381cc9883adcf91219a53d999307dd60b876c8: 19 successful jobs, including lint and all 18 Linux/macOS/Windows × Python 3.8–3.13 combinations. Every test job reports 73 passed and the same 11 token-required skips. Upstream workflows require maintainer approval.
  • New tests run the actual CLI parsers, file readers/writers and HTTP requests against a local mock server across MAF, individual/GISTIC CNA, fusion and structural-variant inputs. They cover precedence, filtering, valid names/codes/main types, metadata failures, token isolation and preserving an existing output when a later row is invalid.
  • Live public-metadata smoke test against oncotree_2025_10_03: MDS/MPN, ICPN, IPN, MBLNWS, PANEC and a main-type name accepted; BLAH rejected. No live variant annotation or patient data was used.

Fixes #214.

@jfkonecn
jfkonecn requested a review from calvinlu3 November 30, 2026 14:13
@jfkonecn

Copy link
Copy Markdown
Contributor

@calvinlu3 please take a look when you have some time.

@calvinlu3 calvinlu3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firstly, thanks for taking the time to address this issue!

After thinking it over, I'm leaning towards fixing this in oncokb-core repo. The underlying problem is that the OncoKB api accepts an invalid OncoTree code like BLAH and returns generic results instead of an error. Checking in the annotator works around that for annotator users, but anyone calling the api directly still gets the same silent behavior. It also gives the annotator a hard dependency on oncotree.mskcc.org, which would break any firewalled users and add unneccesary dependency.

We'd rather fix this in OncoKB core, where the API should return an error when it can't resolve the tumor type. The annotator would then report those errors with no extra requests and no second service to depend on, and the check would always match what the OncoKB server actually recognizes.

Comment thread AnnotatorCore.py
Comment on lines +419 to +421
if cancer_index >= len(row):
raise TumorTypeValidationError('Missing tumor-type column at input line %s' % reader.line_num)
add(get_cell_content(row, cancer_index), 'input line %s' % reader.line_num)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression here since missing cancer type will stop the script whereas before it will just log a warning and continue. We should maintain the original behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cancer type(OncoTree) validation

3 participants